import Combine
import Foundation

let buttonClicked = PassthroughSubject<Void, Never>()

buttonClicked
    .scan(0, { value, _ in value + 1 })
    .sink(receiveValue: { count in
        print("点击按钮\(count)次")
    })

buttonClicked.send(())
buttonClicked.send(())
buttonClicked.send(())
buttonClicked.send(())

/*
 --- E --- E --- E --- E ------>
 scan(0, { value, _ in value + 1 })
 --- 1 --- 2 --- 3 --- 4 ------>
 */



